#include "common.h" 

int main()
{
  umask(0);
  if(mkfifo(IPC_PATH, 0666) < 0){
    //make fail
    std::cout << "make fail" << std::endl;
  }

  int fd = open(IPC_PATH, O_WRONLY);
  if(fd < 0){
    //open fail
    std::cout << "open fail" << std::endl;
  }

  while(true){
    //in 
    int buf = 0;
    std::cout << "if import is 0, it will exit: ";
    std::cin >> buf;

    if(buf == 0) break;

    ssize_t s = write(fd, &buf, sizeof(int));
    std::cout << "parent operation: " << buf << std::endl;

    if(s < 0){
      //write fail
      std::cout << "parent write fail" << std::endl;
    }//if

  }//while

  return 0;
}//main
